package com.kawa.controller;

import com.kawa.entity.TSysUser;
import com.kawa.userService.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vo.result;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private userService service;

    @GetMapping("/showUsers")
    public List<TSysUser> showUser() {
        return service.getUserList();
    }

    @PostMapping("/addUser")
    public result addUser(@RequestBody TSysUser user) {
        if (service.addUser(user)){
           return result.success(user);
        }else{
           return result.failed(user);
        }
    }
}
